package com.system.insurance.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 时间挫生成方式
 */
public class UniqueValueUtils {
    private static String dateTime = "yyyyMMddHHmmssSSS";

    private static String date = "yyyyMMdd";

    private static String time = "HHmmss";

    public synchronized static String createByDateTime(){

        SimpleDateFormat sdf = new SimpleDateFormat(dateTime);
        String date = sdf.format(new Date());
        return date;
    }

    public static String createByDate(){

        SimpleDateFormat sdf = new SimpleDateFormat(date);
        String date = sdf.format(new Date());

        return date + System.currentTimeMillis();
    }

    public static String createByTime(){

        SimpleDateFormat sdf = new SimpleDateFormat(time);
        String date = sdf.format(new Date());

        return date + System.currentTimeMillis();
    }

    public synchronized static String createTimestamp(){
        return System.currentTimeMillis() + "";
    }

    public static void main(String[] args) {



        System.out.println(UniqueValueUtils.createTimestamp().length() +  "__" + UniqueValueUtils.createTimestamp() );
        System.out.println(UniqueValueUtils.createByDateTime().length()+  "__" + UniqueValueUtils.createByDateTime());
        System.out.println(UniqueValueUtils.createByTime().length()+  "__" + UniqueValueUtils.createByTime());
        System.out.println(UniqueValueUtils.createByDate().length()+  "__" + UniqueValueUtils.createByDate());






    }

}
